package cn.livingCloud.dto;

import cn.livingCloud.entity.user.AccountPrivilege;
import cn.livingCloud.entity.user.Privilege;
import cn.livingCloud.entity.user.User;
import cn.livingCloud.entity.user.UserAccount;
import cn.livingCloud.utils.DateUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by DingJie  on 2015/12/4.
 */
public class UserAccountDto {
    protected String uuid;
    protected String userId;
    protected String username;
    protected Boolean enable;
    protected String last_login_time;
    protected List<Privilege> privilegeList = new ArrayList<>();
    protected UserDto userDto;

    public UserAccountDto() {

    }

    public UserAccountDto(UserAccount userAccount) {
        this.uuid = userAccount.getUuid();
        this.userId = userAccount.getUserId();
        this.username = userAccount.getUsername();
        this.enable = userAccount.isEnable();
        for (AccountPrivilege accountPrivilege : userAccount.getPrivilegeList()) {
            privilegeList.add(accountPrivilege.getPrivilege());
        }
        this.last_login_time = DateUtils.toDateText(userAccount.getLastLoginTime()
                , DateUtils.DEFAULT_DATE_TIME_FORMAT);
        User user = userAccount.getUser();
        if (user != null) {
            this.userDto = new UserDto(user);
        }
    }

    public List getPrivilegeList() {
        return privilegeList;
    }

    public void setPrivilegeList(List<Privilege> privilegeList) {
        this.privilegeList = privilegeList;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public String getLast_login_time() {
        return last_login_time;
    }

    public void setLast_login_time(String last_login_time) {
        this.last_login_time = last_login_time;
    }

    public UserDto getUserDto() {
        return userDto;
    }

    public UserAccountDto setUserDto(UserDto userDto) {
        this.userDto = userDto;
        return this;
    }
}
